from DbServer.DbProjectServer import DbProjectServer
from OutPut.outPut import op


class DbMainServer:
    def __init__(self):
        self.Dpjs = DbProjectServer()

    def searchProject(self, ):
        """
        查询未推送的项目名单
        :return:
        """
        try:
            return self.Dpjs.searchProject()
        except Exception as e:
            op(f'[-]: 查询数据失败, 错误信息: {e}')
            return dict()

    def searchProjectAndUser(self, ):
        """
        查询未推送的项目名单
        :return:
        """
        try:
            return self.Dpjs.searchProjectAndUser()
        except Exception as e:
            op(f'[-]: 查询数据失败, 错误信息: {e}')
            return dict()

    def updateProjectPush(self, project_id, is_push):
        """
        查询未推送的项目名单
        :return:
        """
        try:
            return self.Dpjs.updateProjectPush(project_id, is_push)
        except Exception as e:
            op(f'[-]: 查询数据失败, 错误信息: {e}')
            return dict()
    def searchProjectLostAndUser(self, ):
        """
        查询未推送的项目名单
        :return:
        """
        try:
            return self.Dpjs.searchProjectLostAndUser()
        except Exception as e:
            op(f'[-]: 查询数据失败, 错误信息: {e}')
            return dict()

    def updateProjectLostPush(self, project_id, is_push):
        """
        查询未推送的项目名单
        :return:
        """
        try:
            return self.Dpjs.updateProjectLostPush(project_id, is_push)
        except Exception as e:
            op(f'[-]: 查询数据失败, 错误信息: {e}')
            return dict()

    def updatePushMsgByContent(self, reply_content, reply_user, reply_time, project_name):
        """
        更新回复数据
        :return:
        """
        try:
            return self.Dpjs.updatePushMsgByContent(reply_content, reply_user, reply_time, project_name)
        except Exception as e:
            op(f'[-]:更新回复数据失败: {e}')
            return dict()

    def insertProjectMore(self, data):
        """
       添加邮件解析项目数据
        :return:
        """
        try:
            return self.Dpjs.insertProjectMore(data)
        except Exception as e:
            op(f'[-]: 添加邮件解析项目数据, 错误信息: {e}')
            return False

    def insertProjectLost(self, data):
        """
       添加邮件解析项目数据
        :return:
        """
        try:
            return self.Dpjs.insertProjectLost(data)
        except Exception as e:
            op(f'[-]: 添加邮件解析项目数据, 错误信息: {e}')
            return False

    def inserPushMessage(self, project_id, project_name, projectMsg, push_id, projectPushRoom, push_time):
        """
        添加推送消息记录
        :return:
        """
        try:
            return self.Dpjs.inserPushMessage(project_id, project_name, projectMsg, push_id, projectPushRoom, push_time)
        except Exception as e:
            op(f'[-]: 添加推送消息记录错误, 错误信息: {e}')
            return False

    def inserPushMessageLost(self,  project_name, projectMsg, push_id, projectPushRoom, push_time):
        """
        添加推送消息记录
        :return:
        """
        try:
            return self.Dpjs.inserPushMessageLost(project_name, projectMsg, push_id, projectPushRoom, push_time)
        except Exception as e:
            op(f'[-]: 添加推送消息记录错误, 错误信息: {e}')
            return False


    def searchProjectByOpentime(self, data):
        """
        根据开标时间取项目数据
        :return:
        """
        try:
            return self.Dpjs.searchProjectByOpentime(data)
        except Exception as e:
            op(f'[-]: 根据开标时间取项目数据错误: {e}')
            return False

    def showDistrictUser(self):
        """
        查询县区管理者
        :return:
        """
        try:
            return self.Dpjs.showDistrictUser()
        except Exception as e:
            op(f'[-]: 查询县区管理者: {e}')
            return False

    def searchDayPushInfo(self, time1, time2):
        """
        查询推送日报
        :return:
        """
        try:
            return self.Dpjs.searchDayPushInfo(time1, time2)
        except Exception as e:
            op(f'[-]: 查询推送日报错误: {e}')
            return False


if __name__ == '__main__':
    Ds = DbMainServer()
